#ifndef _CONTROL_H_
#define _CONTROL_H_

#include "win_com.h"

//ChengYu@20140221, disable SCART_TV_MODE_LED_DISPLAY
//#define SCART_TV_MODE_LED_DISPLAY

#ifdef _INVW_JUICE   
#define DISABLE_ALI_INFORBAR 	1
#endif
#define REAL_STANDBY 		SYS_FUNC_ON
#define CONTROL_MBF_NAME	"mbcn"
#define CONTROL_MBF_SIZE	300

#define CONTROL_TASK_STACKSIZE	0x4000
#define CONTROL_TASK_QUANTUM	10
#ifdef _BUILD_OTA_E_
	#define MAIN_MENU_HANDLE		NULL
	#define CHANNEL_BAR_HANDLE		NULL
#else
	#define MAIN_MENU_HANDLE		((POBJECT_HEAD)&g_win_mainmenu)
#ifdef _INVW_JUICE   
	#define CHANNEL_BAR_HANDLE		((POBJECT_HEAD)&g_win_inviewinput)
	#define INVIEWJUICE_HANDLE		((POBJECT_HEAD)&g_win_inviewinput)
#else
	#define CHANNEL_BAR_HANDLE		((POBJECT_HEAD)&g_win_progname)
#endif	
#endif
#define INVALID_HK				0xFFFFFFFF
#define INVALID_MSG				0x00000000
#define C_POPUP_MSG_PASS_CI     0x00000001

#ifdef CI_PLUS_SUPPORT
// CI+ MHEG5 browser
typedef struct 
{
	UINT8 InitialObjectNameLength;	//length of Initial Object Name
	UINT8 *pInitialObjectName;		// Initial Object Name
	UINT32 InitialObjectLength;			//length of Initial Object
	UINT8 *pInitialObject;				// Initial Object
}app_init_object_t;
#endif
#ifdef _DTGSI_ENABLE_
struct running_data_t
{
    UINT16 service_id;
    UINT8 running_status;
};
struct sdt_running_info_t
{
    UINT8 sd_count;
    struct running_data_t running_data[128];
};
#endif
#ifdef _INVW_JUICE   
typedef struct
{
	UINT32 type : 4;
	UINT32 state: 4;
	UINT32 count: 8;
	UINT32 ir_code : 16;
} ALI_IR_KEY_INFO;
#else
typedef struct
{
	UINT32 type : 4;
	UINT32 state: 4;
	UINT32 count: 8;
	UINT32 ir_code : 16;
}IR_KEY_INFO;
#endif
struct ir_key_map_t
{
#ifdef _INVW_JUICE   
	ALI_IR_KEY_INFO	key_info;
#else
	IR_KEY_INFO	key_info;
#endif
	UINT32 ui_vkey;
};  

#define SET_IRCODE(a) ((((a)>>24)<<8)|((a)&0xff))

struct channel_info
{
    UINT8 mode;
    UINT8   internal_group_idx;
    P_NODE  p_node;
};

#if (defined(_MHEG5_V20_ENABLE_) )
typedef enum
{
    UI_MENU_OPEN = 0, 
    UI_MENU_CLOSE, 
    UI_MENU_PROC, 
}UIMenuState_t;
#endif

typedef struct 
{
	UINT8 mode;
    UINT8 group;
    UINT16 channel;
}channel_t;

typedef struct Imagedec_frm_t
{
	UINT8 *frm_y_addr;
	UINT32 frm_y_len;
	UINT8 *frm_c_addr;
	UINT32 frm_c_len;
	UINT32 busy;
}Imagedec_frm,*pImagedec_frm;

typedef UINT32 (*pfn_key_notify_callback)(UINT32 msg_code);
pfn_key_notify_callback ap_set_key_notify_proc(pfn_key_notify_callback pfn_notify);

BOOL 	ap_send_msg(ControlMsgType_t msg_type, UINT32 msg_code, BOOL if_clear_buffer);
void    ap_clear_all_message(void);
UINT32  ap_get_popup_msg(UINT32 flag);	
UINT32  ap_get_key_msg(void);	
UINT32  ap_hk_to_vk(UINT32 start, UINT32 key_info, UINT32* vkey );
UINT32  ap_vk_to_hk(UINT32 start,UINT32 vkey, UINT32* key_info);
UINT8   ap_get_vk(void);
UINT32  ap_get_hk(void);
void osd_ge_init();
void api_stop_play(UINT32 bpause);

UINT32 api_sim_start(struct dmx_device *dmx, enum MONITE_TB sim_type, UINT32 tp_id, UINT32 prog_id, UINT32 prog_number, UINT16 sim_pid, INT8 b_force, sim_notify_callback sim_callback);
INT32 api_sim_callback(UINT32 param);
void api_sim_stop(struct ts_route_info *p_ts_route);
extern INT32 api_sim_callback_for_playback(UINT32 param);

#ifdef USB_MP_SUPPORT
void mp_apcallback(UINT32 event_type,UINT32 param);
void fs_apcallback(UINT32 event_type,UINT32 param);
#endif

UINT32 api_disp_blackscreen(BOOL black, BOOL force);

#endif//_CONTROL_H_

